package com.qidianit.mes.device.service.impl;

import com.github.pagehelper.PageHelper;
import com.qidianit.common.pojo.MESResult;
import com.qidianit.common.util.Constant;
import com.qidianit.mes.device.mapper.ToolsTypeMapper;
import com.qidianit.mes.device.service.ToolsTypeService;
import com.qidianit.mes.pojo.MesToolsType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ToolsTypeServiceImpl implements ToolsTypeService {

    @Autowired
    ToolsTypeMapper toolsTypeMapper;
    @Override
    public MESResult list(String typeCode, String typeName, Integer maintenanceType, int page, int limit) {
        PageHelper.startPage(page,limit);
        List<MesToolsType> list = toolsTypeMapper.list(typeCode,typeName,maintenanceType);
        return MESResult.success(list);
    }

    @Override
    public MESResult add(MesToolsType mesToolsType) {
        mesToolsType.setStatus(1);
        toolsTypeMapper.addMesToolsType(mesToolsType);
        return MESResult.success(Constant.RESPONSE_STATUS_OK);
    }

    @Override
    public MESResult edit(MesToolsType mesToolsType) {
        toolsTypeMapper.editMesToolsType(mesToolsType);
        return MESResult.success(Constant.RESPONSE_STATUS_OK);
    }

    @Override
    public MESResult delete(String id) {
        toolsTypeMapper.deleteMesToolsType(id);
        return  MESResult.success(Constant.RESPONSE_STATUS_OK);
    }


}
